package com.ikkong.platform.controller;

import java.util.List;
import java.util.Map;

import com.ikkong.core.base.BaseController;
import com.ikkong.core.jfinal.ext.kit.JsonKit;
import com.ikkong.core.jfinal.ext.shiro.ClearShiro;
import com.ikkong.core.toolbox.Record;
import com.ikkong.system.controller.base.UrlPermissController;
import com.ikkong.platform.meta.intercept.BankBussinessIntercept;
import com.ikkong.platform.model.BankBussiness;
import com.ikkong.platform.service.BankBussinessService;
import com.ikkong.platform.service.impl.BankBussinessServiceImpl;


/**
 * Generated by Blade.
 * 2018-07-04 10:25:03
 */
public class BankBussinessController extends UrlPermissController {
	private static String CODE = "bankBussiness";
	private static String PERFIX = "tb_bank_bussiness";
	private static String LIST_SOURCE = "BankBussiness.list";
	private static String BASE_PATH = "/platform/bankBussiness/";
	
	BankBussinessService service = new BankBussinessServiceImpl();
	
	public void index() {
		setAttr("code", CODE);
		render(BASE_PATH + "bankBussiness.html");
	}

	public void add() {
		setAttr("code", CODE);
		render(BASE_PATH + "bankBussiness_add.html");
	}

	public void edit() {
		String id = getPara(0);
		BankBussiness bankBussiness = service.findById(id);
		setAttr("model", JsonKit.toJson(bankBussiness));
		setAttr("id", id);
		setAttr("code", CODE);
		render(BASE_PATH + "bankBussiness_edit.html");
	}

	public void view() {
		String id = getPara(0);
		BankBussiness bankBussiness = service.findById(id);
		setAttr("model", JsonKit.toJson(bankBussiness));
		setAttr("id", id);
		setAttr("code", CODE);
		render(BASE_PATH + "bankBussiness_view.html");
	}

	public void list() {
		Object grid = paginate(LIST_SOURCE,new BankBussinessIntercept());
		renderJson(grid);
	}

	public void save() {
		BankBussiness bankBussiness = mapping(PERFIX, BankBussiness.class);
		boolean temp = service.save(bankBussiness);
		if (temp) {
			renderJson(success(SAVE_SUCCESS_MSG));
		} else {
			renderJson(error(SAVE_FAIL_MSG));
		}
	}

	public void update() {
		BankBussiness bankBussiness = mapping(PERFIX, BankBussiness.class);
		//bankBussiness.setVersion(bankBussiness.getVersion()+1);
		boolean temp = service.update(bankBussiness);
		if (temp) {
			renderJson(success(UPDATE_SUCCESS_MSG));
		} else {
			renderJson(error(UPDATE_FAIL_MSG));
		}
	}
	


	public void remove() {
		String ids = getPara("ids");
		int cnt = service.deleteByIds(ids);
		if (cnt > 0) {
			renderJson(success(DEL_SUCCESS_MSG));
		} else {
			renderJson(error(DEL_FAIL_MSG));
		}
	}
}
